package edu.scau.comeva.rigcontrol.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: Dan
 * Date: 13-8-15
 * Time: 下午11:21
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table
public class m_account implements Serializable{
    private long acc_id;
    private String acc_name;
    private String acc_pass;
    private m_accountDetl accountDetl;
    private Set<m_role> acc_roles;
    private m_class acc_class;

    @Id
    @GeneratedValue
    public long getAcc_id() {
        return acc_id;
    }

    public void setAcc_id(long acc_id) {
        this.acc_id = acc_id;
    }

    public String getAcc_name() {
        return acc_name;
    }

    public void setAcc_name(String acc_name) {
        this.acc_name = acc_name;
    }

    public String getAcc_pass() {
        return acc_pass;
    }

    public void setAcc_pass(String acc_pass) {
        this.acc_pass = acc_pass;
    }

    @OneToOne(mappedBy = "accDet_acc",cascade = CascadeType.ALL)
    public m_accountDetl getAccountDetl() {
        return accountDetl;
    }

    public void setAccountDetl(m_accountDetl accountDetl) {
        this.accountDetl = accountDetl;
    }

    @ManyToMany(mappedBy = "role_accounts",cascade = CascadeType.ALL)
    public Set<m_role> getAcc_roles() {
        return acc_roles;
    }

    public void setAcc_roles(Set<m_role> acc_roles) {
        this.acc_roles = acc_roles;
    }

    @ManyToOne
    @JoinTable(
            name = "m_account_class",
            joinColumns = @JoinColumn(name = "fk_account_id",referencedColumnName = "acc_id"),
            inverseJoinColumns = @JoinColumn(name = "fk_class_id",referencedColumnName = "cla_id")
    )
    public m_class getAcc_class() {
        return acc_class;
    }

    public void setAcc_class(m_class acc_class) {
        this.acc_class = acc_class;
    }
}
